﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Lilium.Web.Mvc
{
	public struct EntityActionKey : IEquatable<EntityActionKey>
	{
		public EntityActionKey(EntityActionType actionType, Type entityType)
		{
			if (entityType == null) throw new ArgumentNullException("entityType");

			m_ActionType = actionType;
			m_EntityType = entityType;
		}

		public override bool Equals(object obj)
		{
			if (obj is EntityActionKey)
				return Equals((EntityActionKey)obj);
			else
				return base.Equals(obj);
		}

		public override int GetHashCode()
		{
			return ActionType.GetHashCode() ^ EntityType.GetHashCode();
		}

		#region IEquatable<EntityActionKey> Members

		public bool Equals(EntityActionKey other)
		{
			return (this.EntityType == other.EntityType) && (this.ActionType == other.ActionType);
		}

		#endregion

		#region private Type EntityType

		private readonly Type m_EntityType;

		public Type EntityType
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_EntityType;
			}
		}

		#endregion

		#region private EntityActionType ActionType

		private readonly EntityActionType m_ActionType;

		public EntityActionType ActionType
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_ActionType;
			}
		}

		#endregion
	}
}
